package com.tianji.remark.task;

import com.tianji.remark.service.ILikedRecordService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
@RequiredArgsConstructor
public class LikeTimesCheckTask {
    private static final List<String> BIZ_TYPES = List.of("QA","NOTE");
    private final ILikedRecordService likedRecordService;

    /**
     * 定时检测点赞数并发送业务方持久化
     */
    @Scheduled(fixedDelay = 20 * 1000)
    public void checkLikedTimes() {
        log.info("点赞次数检查任务开始执行");
        for (String bizType : BIZ_TYPES) {
            likedRecordService.checkLikedTimesAndSendMessage(bizType,30);
        }
    }
}
